fix(j0di3): Validate troopId format before proxying#1166
Open
jeromehardaway wants to merge 2 commits into
Open
fix(j0di3): Validate troopId format before proxying#1166jeromehardaway wants to merge 2 commits into
jeromehardaway wants to merge 2 commits into
Conversation
A malformed troopId (stale session, botched migration) previously reached the external J0dI3 API and surfaced as an unhelpful 4xx/5xx. The proxy now rejects non-UUID troopIds with a 400 and a user-actionable message before any upstream call, logging the rejected value redacted (first 4 chars + length) so the origin can be investigated. Troop IDs are UUIDs per the registration response stored by ensure-troop and the schema annotation on User.troopId. The pattern accepts any UUID version rather than over-restricting to v4.
npm run typecheck and the staged-file Biome hook failed on master in the j0di3 route tests: unused imports flagged by noUnusedLocals, property assignment onto a Mock type, and the banned Function type in proxy mock signatures. Fixed minimally so verification passes; no test behavior changes.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
src/lib/j0di3-proxy.tsonly checkedif (!troopId)before injecting the troop ID into upstream J0dI3 requests. A malformedtroopId(stale session, botched migration) reached the external J0dI3 API and surfaced to users as an unhelpful 4xx/5xx.Solution
ensure-troop.tsstoresdata.idfrom the J0dI3 registration response, andprisma/schema.prismaannotatesUser.troopIdas "J0dI3 troop UUID". No evidence pins the version to v4, so the proxy validates against a generic UUID pattern (8-4-4-4-12 hex, any version) rather than over-restricting.dispatchreturns400 {"error": "Invalid troop profile. Please sign out and sign back in."}before any upstream call.console.warn(first 4 chars + length, never the full value) so the origin can be investigated.The second commit fixes pre-existing typecheck and Biome errors in the j0di3 route tests (unused imports, property assignment onto a
Mock, bannedFunctiontype in mock signatures) that failed verification on the master baseline. No test behavior changes.Verification
npm run typecheck— passnpm run lint— j0di3 area clean; 19 pre-existing errors remain in unrelated files (components, containers, scripts, pages) that also fail on master and are out of scope herenpm test— 41 files, 386 tests passednpm run build— passCloses #1066